<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
	<head>
		<base href="<%=basePath%>">

		<title>新增用户</title>
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>css/bootstrap.css">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>css/theme.css">
		<script src="<%=basePath%>jquery/jquery.min.js"
			type="text/javascript"></script>
		<script type="text/javascript">
			$(function(){
				$(":input[name='username']").change(function(){
					var val = $(this).val();
					val = $.trim(val);
					
					if(val != null){
						var url = "<%=basePath%>ajax/regist";
						var args = {"username" : val};
						
						$.post(url , args, function(data){
							$("#message").html(data);
						})
					}
				}) 
				
			$(":input[name='email']").blur(function(){
				 var x=$(this).val();
				 var reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
				 if(!reg.test(x))
					 {
					     $(".display2").html("邮箱格式不正确").css("color","red");
					 }else{
						 $(".display2").html("格式正确").css("color","green");
					 }
			 })
		 })	
		</script>		
   </head>

	<body class="content1">
		<div class="header">
			<h1 class="page-title">
				新增用户
			</h1>
		</div>

		<ul class="breadcrumb">
			<li>
				<a href="index.html">用户管理</a>
				<span class="divider">/</span>
			</li>
			<li class="active">
				新增用户
			</li>
		</ul>

		<div class="container-fluid">
			<div class="row-fluid">
				<form method="post" action="<%=basePath%>user/add">
					<div class="btn-toolbar">
						<input type="submit" class="btn btn-primary" value="保存 ">
						<a href="<%=basePath%>user/list" class="btn">取消</a>

					</div>

					<div class="well">
						<div class="tab-pane active in">
							<label>
								用户名：
							</label>
							<input type="text" name="username" maxlength="10" required="required"
							placeholder="请输入用户名">
							<i id="message">
							</i>
							<label>
								用户密码:
							</label>
							<input type="text" name="password" maxlength="10" required="required"
							placeholder="请输入密码">
							<label>
								电话:
							</label>
							<input type="text" name="tel" maxlength="11" required
							placeholder="请输入11位电话" pattern="\d{11}">
							<label>
								email:
							</label>
							<input type="text" name="email" maxlength="50" required="required"
							placeholder="请输入email" ><i class="display2"></i>
							<label>
								用户状态：
							</label>
							<select name="userstate">
								<option value="1">
									正常
								</option>
								<option value="0">
									锁定
								</option>
							</select>
							<label>
								用户角色：
							</label>
							<select name="roleid">
							    <option value="">
								           请选择...
								 </option>
								<c:forEach items="${rolelist}" var="list">
								   <option value="${list.roleid}">
								       ${list.rolename}
								   </option>
								</c:forEach>
							</select>
							<input type="hidden" value="0" name="member"/>
							<div style="color: red">
								${msg}
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</body>
</html>
